<!DOCTYPE html>
<HTML>
<head>
    <title>用户登录</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" th:href="@{/jquery-weui/lib/weui.css}">
    <link rel="stylesheet" th:href="@{/jquery-weui/css/jquery-weui.css}">
    <style>
        body, html {
            height: 100%;
            margin: 0;
        }
        .container {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100%;
        }
    </style>
</head>
<body>
<div class="container">
</div>
</body>
<script type="text/javascript" th:src="@{/jquery-weui/lib/jquery-2.1.4.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jquery-weui/lib/fastclick.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jquery-weui/js/jquery-weui.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jsfiles/crypto-js.min.js?t=1}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jsfiles/com.js}" charset="utf-8"></script>
<script type="text/javascript">
    //后端地址
    var url = "[[${serverUrl}]]/stamp/h5/api/";
    //回跳地址
    var backUrl = "[[${backUrl}]]";
    //回跳地址
    var code = "[[${code}]]";
    //回跳地址
    var state = "[[${state}]]";
    function wxdl(){
        $.showLoading("登录中...");
        var jsonData = {
            backurl: backUrl,
            code: code,
            state: state,
            timestamp:new Date().getTime()
        };
        $.ajax({
            type:"post",
            url:url+"login_do_wx",
            dataType:"json",
            data:JSON.stringify(jsonData),
            timeout : 10*1000, //超时时间设置，单位毫秒
            crossDomain: true,
            contentType: 'application/json;charset=UTF-8',
            beforeSend: function(request) {
                request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
            },
            success:function(result){
                if (result.code==0){
                    try{
                        let rtn = JSON.parse(decrypt_str_fix(result.data));
                        let token_h5 = rtn.token_h5;
                        let a_h5 = rtn.a_h5;
                        let b_h5 =rtn.b_h5;
                        let c_h5 =rtn.c_h5;
                        if (""==token_h5 || ""==a_h5 || ""==b_h5 || ""==c_h5){
                            alert("登录返回数据丢失！");
                        }else{
                            //存储字段
                            localStorage.setItem("a_h5",a_h5);
                            localStorage.setItem("b_h5",b_h5);
                            localStorage.setItem("c_h5",c_h5);
                            localStorage.setItem("token_h5",token_h5);
                            //跳转
                            window.location.href=backUrl;
                        }
                    }catch (e){
                        alert(e);
                    }

                }else{
                    alert("登录发生错误！");
                }
            },
            error:function(result){
                alert("登录发生错误！");
            },complete:function(){
                $.hideLoading();
            }
        });
    }

    wxdl();
</script>
</html>